How to create a link from a link using DXL

Dear All,

I would like to know if you guys can help me.

In my case I have the following scenario:

1. "Formal Module A" <is linked by> "Formal Module B" (IN LINK)
2. "Formal Module B" <links to> "Formal Module C" (OUT LINK).

I want to create a view in "Formal Module A" that show the respective attribute that is in "Formal Module C".

Example: "Formal Module A" [1] linked by "Formal Module B" [2] that link "Formal Module C" [3].
So, I want to show in "Formal Module A" 3.

I tried to create a DXL script, but I didnt figure out how to make a link from a link.

Thanks.
lupsanto - Tue Feb 01 07:59:29 EST 2011

Re: How to create a link from a link using DXL
llandale - Tue Feb 01 15:25:10 EST 2011

Your nomencature is a little confusing, but it looks like module B links to both A and C.

So you want a Layout or Attr DXL in A that finds all in-linked B objects, then finds all out-linked C objects, then summarizes C. It makes sense to show C only once even when there are multiple paths to it (different linked B objects).

This should get you started

Skip skpB = create() // B objects linked to this A object
Skip skpC = create() // C objects linked from the B objects
 
Object oA = obj  // easier to read
Object oB, oC
Link   lnk
 
          // Load module B and C invisible read only Standard vies
read(NameBModule, false, true)
read(NameCModule, false, true)
 
          // [1] Gather B objects
for lnk in oA <-"*" do
{  oB = source(lnk)
   if (null oB)    continue
   if (oB is not in module B) continue
   put(skpB, oB, oB)
}
          // [2] Gather C objects
for oB in skpB do
{  for lnk in oB ->"*" do
   {  oC = target(lnk)
      if (null oC)   continue
      if (oC is not in module C) continue
      put(skpC, oC, oC)
   }
}
         // [3] Summarize C objects
Buffer buf = create
string EOL = ""
for oC in skpC do
{  buf += EOL
   buf += identifier(oC)
   buf += "\t"
   buf += whatever else about C
   EOL  = "\n"   // get ready for next display
}
string Results = stringOf(buf)
delete(buf)
delete(skpB)
delete(skpC)
        // [4] Display Results
obj.attrDXLName = Results

 

  • Louie

 

Re: How to create a link from a link using DXL
SystemAdmin - Tue Feb 01 17:59:37 EST 2011

Louie has provided you with a script but something you should consider in future with DOORS is that it is best practice to try and design your linking schema so that all links follow in one direction - the terms often used are "Top-Down" (high level specs to lower level specs) or the reverse "Bottom-Up" link direction schemas. The most popular is the "Bottom-Up" link direction schema as this has advantages with respect to link ownership & management responsibility. This is not always 100% possible although I have found it be very rare when it cannot be 100%.

By having your links following one direction only, this would have allowed you to take full advantage of DOORS features like the Analysis Wizard which would have gone a long way towards solving your problem.


Paul Miller
Melbourne, Australia

Re: How to create a link from a link using DXL
lupsanto - Wed Feb 02 05:49:40 EST 2011

SystemAdmin - Tue Feb 01 17:59:37 EST 2011
Louie has provided you with a script but something you should consider in future with DOORS is that it is best practice to try and design your linking schema so that all links follow in one direction - the terms often used are "Top-Down" (high level specs to lower level specs) or the reverse "Bottom-Up" link direction schemas. The most popular is the "Bottom-Up" link direction schema as this has advantages with respect to link ownership & management responsibility. This is not always 100% possible although I have found it be very rare when it cannot be 100%.

By having your links following one direction only, this would have allowed you to take full advantage of DOORS features like the Analysis Wizard which would have gone a long way towards solving your problem.


Paul Miller
Melbourne, Australia

Thank you all!

Well done.

I did some modifications in DXL script and the script below works fine.

pragma runLim, 0
int cont = 0

// display change proposals
{
 
   // check status
   if ((current Project) != null)
    {
    string sCPModulePath = null
        Module m = current
        string this_module = fullName(m)
 
 
        // ensure proposal module is open
        
                        LinkRef lr
                        Link OUT
 
            // process in-links
            for lr in (obj <- S_MOD_CPLINKS_PATH()) do 
            {
                sCPModulePath = fullName(source lr)
 
                                        // only relevant if module exists with r access
                                 if (exists(module sCPModulePath) == true)
                                {
                                                // only relevant if module is closed
                                                if (open(module sCPModulePath) == false)
                                                        {
                                                        // ensure module is open 
                                                        read(sCPModulePath, false)
                                                        }
                                                        break           
 
                                }
        }
                
        // only relevant if module exists with r access
                  if (exists(module sCPModulePath) == true)
                                 {
                                        Link l
                                        Link R
                                        // process in-links
                                        for l in obj <- (S_MOD_CPLINKS_PATH()) do
                                        {
                                                Object oProposal = source l
                                                // check status
                                                if (oProposal != null)
                                                {
                                                        string sStatus = probeAttr_(oProposal, S_ATTR_STATUS)
 
                                                        // only relevant for proposals that are not rejected or applied
                                                        if (sStatus != S_REJECTED)
                                                        {                       
                                                        // padding
 
                                                                for R in (oProposal -> "*") do
                                                                {
                                                                sCPModulePath2 = fullName(target R)
                                                                if (open(module sCPModulePath2) == false){
                                                                        read(sCPModulePath2, false)
                                                                }
                                                                Object oProposal2 = target R
                                                                if (fullName(target R) != this_module){
                                                                        display "CP: "probeAttr_(oProposal2, "Absolute Number")
                                                                }
                                                                }
                                                        }
                                                }
                                        }
                }
        if (isLastObjectInDXLSet obj){
            string cpsModName = fnGetCPModulePath(fullName(module(obj)))
            Module cpsMod = read (cpsModName, false) 
            // cpsMod will be NULL if cps is not configured for this module.
            // Don't close the module if it is open visible (i.e. CP partner is open).
            if (null != cpsMod && !isVisible(cpsMod)){ 
                close cpsMod
            }
        }
    }
}